package com.talos.ums.dal.mysql.organization;

import com.talos.framework.common.pojo.PageResult;
import com.talos.framework.mybatis.core.mapper.BaseMapperX;
import com.talos.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.talos.ums.controller.admin.organization.vo.UmsOrganizationPageReqVO;
import com.talos.ums.dal.dataobject.organization.UmsOrganizationDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 组织表 Mapper
 *
 * @author ${table.author}
 */
@Mapper
public interface UmsOrganizationMapper extends BaseMapperX<UmsOrganizationDO> {

    default PageResult<UmsOrganizationDO> selectPage(UmsOrganizationPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UmsOrganizationDO>()
                .eqIfPresent(UmsOrganizationDO::getCode, reqVO.getCode())
                .likeIfPresent(UmsOrganizationDO::getName, reqVO.getName())
                .eqIfPresent(UmsOrganizationDO::getParentId, reqVO.getParentId())
                .eqIfPresent(UmsOrganizationDO::getParentCode, reqVO.getParentCode())
                .eqIfPresent(UmsOrganizationDO::getLevel, reqVO.getLevel())
                .eqIfPresent(UmsOrganizationDO::getSort, reqVO.getSort())
                .eqIfPresent(UmsOrganizationDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(UmsOrganizationDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(UmsOrganizationDO::getCreatorCode, reqVO.getCreatorCode())
                .likeIfPresent(UmsOrganizationDO::getCreatorName, reqVO.getCreatorName())
                .betweenIfPresent(UmsOrganizationDO::getModifyTime, reqVO.getModifyTime())
                .eqIfPresent(UmsOrganizationDO::getModifierCode, reqVO.getModifierCode())
                .likeIfPresent(UmsOrganizationDO::getModifierName, reqVO.getModifierName())
                .eqIfPresent(UmsOrganizationDO::getIsSettlementOrg, reqVO.getIsSettlementOrg())
                .eqIfPresent(UmsOrganizationDO::getDeleted, reqVO.getDeleted())
                .eqIfPresent(UmsOrganizationDO::getOrganizationCodeTree, reqVO.getOrganizationCodeTree())
                .eqIfPresent(UmsOrganizationDO::getOrganizationIdTree, reqVO.getOrganizationIdTree())
                .eqIfPresent(UmsOrganizationDO::getOrganizationTypeCode, reqVO.getOrganizationTypeCode())
                .eqIfPresent(UmsOrganizationDO::getTenantCode, reqVO.getTenantCode())
                .eqIfPresent(UmsOrganizationDO::getTenantId, reqVO.getTenantId())
                .eqIfPresent(UmsOrganizationDO::getCreatorId, reqVO.getCreatorId())
                .eqIfPresent(UmsOrganizationDO::getModifierId, reqVO.getModifierId())
                .orderByDesc(UmsOrganizationDO::getId));
    }

}
